<?php

namespace App\Admin\Controllers;

use App\Models\Gather;
use App\Models\HistoryWin;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;

class StatisticsController extends AdminController
{
    public function gather(Content $content)
    {
        $list = Gather::select('odd_num','max_cont', \DB::raw('count(*) as sum'))
            ->groupBy('odd_num','max_cont')
            ->orderBy('sum','desc');

        return $content->title('集合分析')->description('概率')->body(
            Grid::make($list, function (Grid $grid) {
                $grid->column('odd_num','奇数个数');
                $grid->column('max_cont','最大连号');
                $grid->column('sum','数量');
                $grid->disableCreateButton();
                $grid->disableActions();

            })
        );
    }

    public function history(Content $content)
    {
        $list = HistoryWin::select('odd_num','max_cont', \DB::raw('count(*) as sum'))
            ->groupBy('odd_num','max_cont')
            ->orderBy('sum','desc');

        return $content->title('集合分析')->description('概率')->body(
            Grid::make($list, function (Grid $grid) {
                $grid->column('odd_num','奇数个数');
                $grid->column('max_cont','最大连号');
                $grid->column('sum','数量');
                $grid->disableCreateButton();
                $grid->disableActions();

            })
        );
    }

}
